function [ lpimg ] = my_idealLowPassFilter( img,maxFrequency )
%MY_IDEALLOWPASSFFT preforms an ideal low pass filter with the min.
% the result only contains frequencies lower maxFrequency. 

    %get images size for filtermask and temprary Image
    [sY,sX] = size(img);
    %generate fft2 version of image and shift zero-frequencies to center
    Filter = fftshift( fft2(double(img)) );
    %temporary image and resulting image (as tranformation)
    tmp = double(zeros(sY,sX)); newImg = double(zeros(sY,sX));
   
    %traverse through each pixel
    for y = 1:sY
        for x = 1:sX           
            tmp(y,x) = sqrt( ((y-(sY/2))^2) + ((x-(sX/2))^2) );
            %just use the pixel which are below or equal the maxFrequency
            newImg(y,x) = (tmp(y,x)<=maxFrequency) * Filter(y,x);
        end
    end
    
    %get the "old" center shifted zero-frequencies and inverse the 
    %fourier transformed picture to get the resulting image
    lpimg = ifft2( ifftshift(newImg) );
    
end

